package com.llh.demo4session.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

/**
 * <p>CreatedAt: 2020/9/3 10:06</p>
 *
 * @author llh
 */
@Configuration
@EnableRedisHttpSession
public class SessionConfig {
    @Bean
    public LettuceConnectionFactory connectionFactory() {
        RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
        // 使用redis的3号库
        // 默认库写了太多其他的东西
        // 此处redis的配置与配置文件中redis的属性是独立的
        configuration.setDatabase(3);
        return new LettuceConnectionFactory(configuration);
    }
}
